//
//  LJP_PlayerHeadView.m
//  God_is_a_Girl
//
//  Created by 李继鹏 on 15/10/6.
//  Copyright (c) 2015年 呸. All rights reserved.
//

#import "LJP_PlayerHeadView.h"
#import <UIImageView+WebCache.h>
#import "LJP_GuideCellModel.h"
@implementation LJP_PlayerHeadView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        UIVisualEffectView *effect = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]];
        effect.frame = CGRectMake(0, 0, frame.size.width, frame.size.height);
        effect.alpha = 1;
        [self addSubview:self.backView];
        [self addSubview:effect];
        self.picture = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
        self.picture.center = CGPointMake([UIScreen mainScreen].bounds.size.width / 2, 195);
        self.backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.backButton.frame = CGRectMake(20, 30, 30, 30);
        [self.backButton setBackgroundImage:[UIImage imageNamed:@"PlayBack"] forState:UIControlStateNormal];
        self.name = [[UILabel alloc] initWithFrame:CGRectMake(55, 30, [UIScreen mainScreen].bounds.size.width - 100, 30)];
        self.name.textColor = [UIColor whiteColor];
        self.name.font = [UIFont systemFontOfSize:16];
        self.name.textAlignment = NSTextAlignmentCenter;
//        self.slider = [[Slider alloc] initWithFrame:CGRectMake(5, 300, [UIScreen mainScreen].bounds.size.width - 10, 20)];
        self.sound = [UIButton buttonWithType:UIButtonTypeCustom];
        self.sound.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 40, 30, 30, 30);
        [self.sound setBackgroundImage:[UIImage imageNamed:@"jingyin"] forState:UIControlStateNormal];
        [self.sound setBackgroundImage:[UIImage imageNamed:@"shengyin"] forState:UIControlStateSelected];
        [self addSubview:self.sound];
        self.lastButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.playButton = [UIButton buttonWithType:UIButtonTypeCustom];
        self.lastButton.frame = CGRectMake(50, 350, 40, 40);
        self.nextButton.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 90, 350, 40, 40);
        self.playButton.frame = CGRectMake(0, 0, 50, 50);
        self.playButton.center = CGPointMake([UIScreen mainScreen].bounds.size.width / 2, 370);
        [self.lastButton setBackgroundImage:[UIImage imageNamed:@"lastButton"] forState:UIControlStateNormal];
        [self.nextButton setBackgroundImage:[UIImage imageNamed:@"nextButton"] forState:UIControlStateNormal];
        [self.playButton setBackgroundImage:[UIImage imageNamed:@"PauseButton"] forState:UIControlStateNormal];
        [self.playButton setBackgroundImage:[UIImage imageNamed:@"PlayButton"] forState:UIControlStateSelected];
        [self addSubview:self.picture];
        [self addSubview:self.backButton];
        [self addSubview: self.name];
//        [self addSubview:self.slider];
        [self addSubview:self.lastButton];
        [self addSubview:self.nextButton];
        [self addSubview:self.playButton];
    }
    return self;
}
- (void)setModel:(LJP_GuideCellModel *)model
{
    if (model != _model) {
        _model = model;
    }
    [self.backView sd_setImageWithURL:[NSURL URLWithString:_model.coverMiddle] placeholderImage:[UIImage imageNamed:@"search"]];
    [self.picture sd_setImageWithURL:[NSURL URLWithString:_model.coverMiddle] placeholderImage:[UIImage imageNamed:@"search"]];
    self.name.text = _model.title;
}

@end
